package models

import (
	"time"
)

type Term struct {
	Size int `json:"size"`
	Page int `json:"page"`
	Total int `json:"total"`
	TotalPage int `json:"totalPage"`
	HasStart bool `json:"hasStart"`
	HasTotal bool `json:"hasTotal"`
	Data interface{} `json:"data"`
}

func (this *Term) Start() int {
	return (this.Page - 1) * this.Size
}

type Json struct {
	Code int `json:"code"`
	Message string `json:"message"`
	Data interface{} `json:"data"`
}

func JsonSuccess(message string, data interface{}) Json {
	return Json{200, message, data}
}
func JsonError(message string) Json {
	return Json{500, message, nil}
}


type User struct {
	Id       int `json:"id"`
	Username string `json:"username"`
	Password string `json:"password"`
}

type Article struct {
	Id        int `json:"id"`
	FirstCid  int `json:"first_cid"`
	SecondCid int `json:"second_cid"`
	ThirdCid  int `json:"third_cid"`
	Title     string `json:"title"`
	Tags      string `json:"tags"`
	Summary   string `json:"summary"`
	Content   string `json:"content"`
	Status    string `json:"status"`
	ImgUrl    string `json:"img_url"`
	Author    string `json:"author"`
	Comments  int `json:"comments"`
	Views     int `json:"views"`
	Updated   time.Time `json:"updated"`
	Created   time.Time `json:"created"`
}

type Seo struct {
	Id          int
	SeoKey      string
	TargetId    int
	Title       string
	Description string
	Keywords    string
	Updated     time.Time
	Created     time.Time
}

type Category struct {
	Id      int `json:"id"`
	Pid     int `json:"pid"`
	Name    string `json:"name"`
	Parent  bool `json:"parent"`
	Level   int `json:"level"`
	Updated time.Time `json:"updated"`
	Created time.Time `json:"created"`
	//Children []Category
}

type Link struct {
	Id   int `json:"id"`
	Name string `json:"name"`
	Url  string `json:"url"`
	Type string `json:"type"`
	Created time.Time `json:"created"`
	Creator int `json:"creator"`
}

type MpConfig struct {
	Id            int;
	AppId         string;
	Name          string;
	Secret        string;
	Token         string;
	AesKey        string;
	AccessToken   string;
	ExpiresTime   int64;
	JsApiTicket   string;
	JsExpiresTime int64;
	PartnerId     string;
	PartnerKey    string;
	CertPath      string;
	CertPass      string;
	Salt          string;
}
